package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 使用指定构造器
 */
public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
            Person p = new Person("刘三",55);
        System.out.println(p);


        Class cls = Class.forName("reflect.Person");
        Constructor c = cls.getConstructor(String.class, int.class);
        Object o = c.newInstance("刘桑", 55);
        System.out.println(o);

    }
}
